package com.example.administrator.familfinalcialmanagement.ui.activity;

import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;

import com.example.administrator.familfinalcialmanagement.R;
import com.example.administrator.familfinalcialmanagement.databinding.ActivityForgetPwdBinding;
import com.example.administrator.familfinalcialmanagement.ui.BaseActivity;
import com.example.administrator.familfinalcialmanagement.ui.view.RegisterTime;
import com.example.administrator.familfinalcialmanagement.util.ToastUtil;

/**
 * Created by SensYang on 2019/03/28 21:43
 */

public class ForgetPwdActivity extends BaseActivity {

    ActivityForgetPwdBinding binding;
    RegisterTime timeUtil;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_forget_pwd);
        binding.setActivity(this);
        initView();
    }

    private void initView() {
        setBack();
        setTitleText("忘记密码");

        binding.textViewCode.setOnClickListener(this);
        binding.textViewUpdata.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.textViewCode:
                String phone = binding.phone.getText().toString().trim();
                if (TextUtils.isEmpty(phone)) {
                    ToastUtil.showLongToast("请输入您的手机号码");
                    return;
                } else {
                    timeUtil = new RegisterTime(60000, 1000, binding.textViewCode);
                    timeUtil.start();
                    ToastUtil.showToast("验证码获取失败");
                }
                break;
            case R.id.textViewUpdata:
                String phoneUpdada = binding.phone.getText().toString().trim();
                if (TextUtils.isEmpty(phoneUpdada) || phoneUpdada.length() != 11) {
                    showInCommonDialog("请输入格式正确的手机号码");
                    binding.phone.setText("");
                    return;
                }

                String code = binding.code.getText().toString().trim();
                if (TextUtils.isEmpty(code) || code.length() != 6) {
                    ToastUtil.showToast("请输入格式正确的验证码");
                    return;
                }

                break;
            default:
        }
    }
}
